package com.action;

import java.io.IOException;
import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;

import com.base.BaseAction;
import com.domain.Function;
import com.service.FunctionService;
import com.util.BOSContext;

import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;
@Controller(value="functionAction")
@Scope("prototype")
public class FunctionAction extends BaseAction<Function> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Resource(name="functionService")
	private FunctionService functionService;
	/**
	 * 查询所有权限
	 * @return
	 */
	public String findAllFunction(){
		List<Function> functionList=functionService.findAllFunction();
		this.writeList2json(functionList, new String[]{"children","roles","parentFunction"});
		return NONE;
	}
	

	/**
	 * 根据登录人权限查询菜单
	 */
	public String findMenu(){
		List<Function> menuList=functionService.findMenu(BOSContext.getUser());
		this.writeList2json(menuList, new String[]{"parentFunction","roles","children"});
		return NONE;
	}
}
